<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="keyword" content="">

    <title>基础文件 - BIM管理</title>

    <!-- Bootstrap core CSS -->
    <link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet">
    <link href="__PUBLIC__/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="__PUBLIC__/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="__PUBLIC__/css/style.css" rel="stylesheet">
    <link href="__PUBLIC__/css/style-responsive.css" rel="stylesheet" />
    <!-- new styles-->
    <link href="__PUBLIC__/css/xxxstyle.css" rel="stylesheet" />
    <link href="__PUBLIC__/css/simple.slide.css" rel="stylesheet"/>
      <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
      <script src="__PUBLIC__/js/html5shiv.js"></script>
      <script src="__PUBLIC__/js/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

  <section id="container" class="">
      <!--main content start-->
      <section id="main-content">
          <section class="wrapper site-min-height">
              <!-- page start-->
              <section class="panel">
                  <header class="panel-heading"><i class="icon-folder-open"></i>{$fname}
                      <span class="pull-right">
                          <button type="button" class="btn btn-default btn-xs" onclick="javascript:window.history.back();return false;"><i class="icon-reply"></i>返回</button>
                          <if condition="$type neq 4">
                         	 <button type="button" class="btn btn-submit btn-xs" data-toggle="modal" href="#uploadFile"><i class="glyphicon glyphicon-open"></i>上传</button>
                          </if>
                      </span>
                  </header>
                  <div class="panel-body borBottom">                                            
                    <div class="input-group searchLine">
                      <input type="text"  name="searchname" placeholder="搜索..." class="input-sm form-control" /> 
                      <span class="input-group-btn">
                        <button type="button" class="btn btn-sm btn-submit searchBtn" onclick="search();"><i class="icon-search"></i></button> 
                      </span>
                    </div>                          
                  </div>              
                 <div id="ajaxgover">
                 
                 </div>
              </section>
              <!-- page end-->
          </section>
          <!-- Modal 上传文件 -->
          <div class="modal fade" id="uploadFile" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
              <div class="modal-dialog bigmodal">
                  <div class="modal-content">
                      <div class="modal-header">
                          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                          <h4 class="modal-title">上传文件</h4>
                      </div>
                      <div class="modal-body">                
                          <div id="upload" class="BasicFileUploadBox"></div>                         
                      </div>
                      <div class="modal-footer">
                          <button class="btn btn-submit" type="button" onclick="out()">完成并关闭</button>
                      </div>
                  </div>
              </div>
          </div>
          <!-- modal -->
      </section>
      <!--main content end-->
  </section>

    <!-- js placed at the end of the document so the pages load faster -->
    <script src="__PUBLIC__/js/jquery.js"></script>
    <script src="__PUBLIC__/js/bootstrap.min.js"></script>
    <script class="include" type="text/javascript" src="__PUBLIC__/js/jquery.dcjqaccordion.2.7.js"></script>
    <script src="__PUBLIC__/js/jquery.scrollTo.min.js"></script>
    <script src="__PUBLIC__/js/jquery.nicescroll.js" type="text/javascript"></script>
    <script src="__PUBLIC__/js/jquery.customSelect.min.js" ></script>
    
    <!--common script for all pages-->
    <script src="__PUBLIC__/js/common-scripts.js"></script>

    <!--new script for this page only-->
    <script type="text/javascript" src="__PUBLIC__/js/jquery.Huploadifyy.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/layer/layer.js"></script>      
    <script type="text/javascript">
      $(document).ready(function(){
          ajaxgover({$cid});
      });
     
      // ajax 抓取页面
      function ajaxgover(cid,page=1,name=''){
    	  var type ={$type};
              $.ajax({
                  type : "POST",
                  url:'__URL__/ajaxgover/p/'+page,
                  data : {cid:cid,name:name,type:type},
                  success: function(data){
                      $("#ajaxgover").html('');
                      $("#ajaxgover").append(data);
                  }
              });
      }
      
    //文件删除
      function dell(obj){
    	if(obj){
    		 $.ajax({
    	          type : "POST",
    	          url:'__URL__/delFile',
    	          data : {filename:obj},
    	          dataType : 'json',
    	          success: function(res){
    	        	  if(res.status==0){
    						layer.alert(res.info, {icon: 2});
    						return;
    					 }
    		 			 if(!res.errNo){
    		 				 layer.msg(res.msg,{icon:1});
    		 				 ajaxgover({$cid});
    			          }else{
    			        	 layer.msg(res.msg,{icon:2});
    			          }
    	          }
    	      });
    	}
     }
    
    //关闭上传弹框
    function out(){
     	var a = $('.uploadbtn').text();
    	if(a.indexOf("上传中...") > 0 || a=='上传中...'){
    		layer.confirm('还有文件正在上传中,关闭后可能导致上传失败,确定关闭吗?', {
    	   		  btn: ['确定','取消'] //按钮
    	  }, function(){
    	   			$('#uploadFile').modal('hide');
    	   			layer.closeAll('dialog');
    	 	}, function(){
    	  			// 取消
    	  });
    	  			return false;
    	}else{
    		$('#uploadFile').modal('hide');
    	} 
    }
      
      //search
      function search(){
    	  var name = $("input[name='searchname']").val();
    	  ajaxgover({$cid},1,name);
      }
      
      $(function(){
    		$('#upload').Huploadify({
      			auto:false,
      			fileTypeExts:'*.jpg;*.png;*.pdf;*.zip;*.doc;*.docx;*.xls;*.xlsx;*.rvt;*.nwd;*.dwg;*.rar',
      			multi:true,
      			formData:{key:{$cid},key2:'vvvv',},
      			fileSizeLimit:204800,
      			showUploadedPercent:true,//是否实时显示上传的百分比，如20%
      			showUploadedSize:true,
      			removeTimeout:9999999,
      			uploader:'/Bim/upload',
      			onUploadStart:function(){
      				//alert('开始上传');
      			},
      			onInit:function(){
      				//alert('初始化');
      			},
      			onUploadComplete:function(file){
      				  // layer.msg('上传完成',{icon:1});
      				  var id = file.id;
      				  var ids = id - 1;
      				  $('.uploadify-queue-item').eq(ids).find('.uploadbtn').text('上传完成');
      				  ajaxgover({$cid},1);
      			},
      			onDelete:function(file){
        				console.log('删除的文件：'+file);
        				console.log(file);
      			},
    		})
    	});
    </script>
  </body>
</html>
